<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
require "../config.php";
require "../libs/db_functions.php";
$story_id =  isset($_GET['story_id'])? $_GET['story_id'] : 1;
  CONNECT_DB();
    mysql_query("SET NAMES utf8");
	
	$table_name = 'story_id_'.$story_id;
	$sql="SELECT chapter_id, chapter_name FROM $table_name";
	//echo $sql; exit();
	$result=mysql_query($sql);
	$data=array();
	$data[]=array();
	$index=0;
	while($rows=mysql_fetch_array($result)){
      $data[$index]=$rows;
	  $index++;
    }
	echo json_encode($data);
	//echo '<pre>';print_r($data); echo '</pre>';     
?> 